!function($){
    // document ready

    $(function(){


        $('.noel-popup-close').click(function(e) {
                $(this).parent().removeClass("visible");

                return false;
        });


        // $('.template-nav a#p1, .template-nav a#p2, .template-nav a#p3, .template-nav a#p4, .template-nav a#p5').click(function () {
        //     $(this).addClass('template-active').parent().siblings().children().removeClass('template-active');
        // });


        $('.js-opentopmenu').click(function(e){
            e.preventDefault();
            $('ul#ul').slideToggle(400);
        })


        var $baseElement = $('#content');

        // Modal box
        var $circleModalElement = $('.noel-popup');
        var $clickElement;
        var positionClass = '';
        var hoverTimeout;
        var circlePosition = {
            // top: 50,
            // left: 30
        };
        var modalType = '';

        function modalClear() {
            $circleModalElement.find('.noel-popup-title').text('');
            $circleModalElement.find('.noel-popup-desc').text('');

            $circleModalElement.find('img').attr('src', '');
            $circleModalElement.find('img').attr('alt', '');

        };

        $('.noel-has-modal').click(function() {
            $clickElement = $(this);
            // aleret("asdads");

            // $circleModalElement.removeClass(positionClass);
            // positionClass = $clickElement.data('positionclass') ? $clickElement.data('positionclass') : 'zi-modal-left';

            // modalType = $clickElement.data('modaltype');
            // if (modalType) {
            //     $circleModalElement.addClass(modalType);
            // }

                modalClear();

            // circlePosition.top = $clickElement.offset().top - $baseElement.offset().top + $clickElement.height()*(-11);
            // circlePosition.left = $clickElement.offset().left - $baseElement.offset().left + $clickElement.width()*1.5;

            // if (positionClass == 'zi-modal-left') {
            //     circlePosition.left +=  $clickElement.width()*3;
            // }
            // else if (positionClass == 'zi-modal-right') {
            //     circlePosition.left -=  $circleModalElement.width()*(-0.1);
            // }

            $circleModalElement.addClass(positionClass);


            $circleModalElement.find('.noel-popup-title').text($clickElement.data('title'));
            $circleModalElement.find('.noel-popup-desc').text($clickElement.data('description'));


            $circleModalElement.find('img').attr('src', $clickElement.data('buttonurl'));
            $circleModalElement.find('img').attr('alt', $clickElement.data('titlelink'));

            $circleModalElement.css({
                top: circlePosition.top,
                left: circlePosition.left
            });

            $circleModalElement.addClass('visible');

            return false;

        });

    });

}(jQuery);
